<template>
<div>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="姓名">
      <el-col :span="11">
      <el-input v-model="form.name"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item label="选择生日">
      <el-col :span="11">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.birthday" style="width: 100%;"></el-date-picker>
      </el-col>
    </el-form-item>


    <el-form-item label="性别">
      <el-col :span="3">
      <el-radio-group v-model="form.sex">
        <el-radio label="男"></el-radio>
        <el-radio label="女"></el-radio>
      </el-radio-group>
      </el-col>
    </el-form-item>

    <el-form-item label="公司">
      <el-col :span="11">
        <el-input v-model="form.company"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item label="职位">
      <el-col :span="11">
        <el-input v-model="form.position"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item label="手机">
      <el-col :span="11">
        <el-input v-model="form.mobile"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item>
      <el-col :span="11">
      <el-button type="primary" @click="onSubmit">新增名片</el-button>
      <el-button>取消</el-button>
      </el-col>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
export default {
  name: "CardAdd",

  data() {
    return {
      form: {
        name: '',
        birthday: '',
        sex: '',
        company: '',
        position: '',
        mobile: ''
      }
    }
  },
  methods: {
    onSubmit() {
      let  vm = this;
      this.axios({
        url:"http://localhost:9090/card/add",
        method:"POST",
        data:vm.form
      }).then(function (res){
        console.log(res)
        if (res.data.code==0){
          vm.$message.success("名片新增成功"),
            setTimeout(function (){
              vm.$router.push("cardList")
            },1000);

        }
      });
    }
  }
}
</script>

<style scoped>

</style>
